//
//  UILabel+Extension.swift
//  SinaWeibo
//
//  Created by mac on 15/11/30.
//  Copyright © 2015年 mac. All rights reserved.
//

import UIKit

extension UILabel {
    
    convenience init(title : String , color : UIColor , fontSize : CGFloat ,margin: CGFloat = 0) {
       self.init()
    
    text = title
    
    textColor = color
   
    font = UIFont.systemFontOfSize(fontSize)
    
//        设置文字自动换行
    numberOfLines = 0
        
//        设置文字显示居中
    textAlignment = NSTextAlignment.Center
        
        if margin > 0 {
            preferredMaxLayoutWidth = screenW - 2 * margin
            textAlignment = NSTextAlignment.Left
        }
        
    sizeToFit()
 
    }
    
}

